# 连接数据库
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List, Optional, Dict, Any
# 数据库表结构
from module_admin.entity.vo.employee_social_security_vo import EmployeeSocialSecurityQueryModel
# 数据库操作层
from module_admin.dao.employee_social_security_dao import EmployeeSocialSecurityDao
# 下划线形式(snake_case)转小驼峰形式(camelCase)工具方法
from utils.common_util import CamelCaseUtil
from utils.page_util import PageUtil
from datetime import datetime


class EmployeeSocialSecurityService:
    """
    员工社保模块服务层
    """

    @classmethod
    async def get_employee_social_security_list_services(cls, db: AsyncSession, security_query: EmployeeSocialSecurityQueryModel):
        """
        获取员工社保列表信息

        :param db: orm对象
        :param security_query: 查询参数对象
        :return: 员工社保列表信息对象
        """
        security_list = await EmployeeSocialSecurityDao.get_employee_social_security_list(db, security_query)
        return security_list

    @classmethod
    async def get_employee_social_security_services(cls, db: AsyncSession, security_id: int):
        """
        获取单个员工社保详情
        :param db: orm对象
        :param security_id: 社保ID
        :return: 员工社保详情
        """
        security = await EmployeeSocialSecurityDao.get_employee_social_security(db, security_id)
        return security

    @classmethod
    async def add_employee_social_security_services(cls, db: AsyncSession, security: EmployeeSocialSecurityQueryModel):
        """
        新增员工社保信息
        :param db: orm对象
        :param security: 新增社保对象
        :return: 新增结果
        """
        security.create_time = datetime.now()
        security.update_time = datetime.now()
        result = await EmployeeSocialSecurityDao.add_employee_social_security(db, security)
        return result

    @classmethod
    async def update_employee_social_security_services(cls, db: AsyncSession, security_id: int, security: EmployeeSocialSecurityQueryModel):
        """
        修改员工社保信息
        :param db: orm对象
        :param security_id: 社保ID
        :param security: 修改社保对象
        :return: 修改结果
        """
        security.update_time = datetime.now()
        result = await EmployeeSocialSecurityDao.update_employee_social_security(db, security_id, security)
        return result

    @classmethod
    async def delete_employee_social_security_services(cls, db: AsyncSession, security_id: int):
        """
        删除员工社保信息
        :param db: orm对象
        :param security_id: 社保ID
        :return: 删除结果
        """
        result = await EmployeeSocialSecurityDao.delete_employee_social_security(db, security_id)
        return result

    @classmethod
    async def export_employee_social_security_services(cls, db: AsyncSession, security_query: EmployeeSocialSecurityQueryModel):
        """
        导出员工社保信息
        :param db: orm对象
        :param security_query: 查询参数对象
        :return: 导出结果
        """
        security_list = await EmployeeSocialSecurityDao.get_employee_social_security_list(db, security_query, is_page=False)
        return security_list 